package org.gordonframework.site.forms.elements.skins {
	import org.gordonframework.core.graphics.GColor;
	import org.gordonframework.site.forms.elements.GElement;
	import org.gordonframework.site.forms.elements.formats.GElementSkinFormatFactory;
	import org.gordonframework.site.views.GLabel;
	import org.gordonframework.site.views.GView;
	
	import flash.geom.ColorTransform;	

	/**
	 * @author eriarv
	 */
	public class GElementSkin extends GView {

		protected var formatFactory : GElementSkinFormatFactory;
		protected var label : GLabel;
		
		protected var format : Object;
		protected var textFormats : Object;
		
		public function GElementSkin() {
			super();
			formatFactory = GElementSkinFormatFactory.getInstance();
		}

		public function update( element : GElement ) : void {
			format = formatFactory.getSkinFormatForType(element.type);
			textFormats = formatFactory.getTextFormatForType(element.type);
		}

		public function set valid( value : Boolean ) : void {
			var focusColor : uint = formatFactory.getSkinFormatForType(GElement.TYPE).focus.color;			
			if ( value ) {
				label.transform.colorTransform = new ColorTransform();
			} else {
				label.transform.colorTransform = GColor.tint( focusColor );
			}
		}
	}
}
